/*
 * CrearRubro.java
 *
 * Created on 14-oct-2008, 16:16:25
 */
 
package investigaciones_itm.Presupuestos;

import com.sun.rave.faces.data.DefaultSelectItemsArray;
import com.sun.rave.web.ui.appbase.AbstractPageBean;
import com.sun.webui.jsf.component.Body;
import com.sun.webui.jsf.component.Calendar;
import com.sun.webui.jsf.component.DropDown;
import com.sun.webui.jsf.component.Form;
import com.sun.webui.jsf.component.Head;
import com.sun.webui.jsf.component.Html;
import com.sun.webui.jsf.component.Link;
import com.sun.webui.jsf.component.Page;
import com.sun.webui.jsf.component.PanelLayout;
import com.sun.webui.jsf.component.Tab;
import com.sun.webui.jsf.component.TabSet;
import com.sun.webui.jsf.component.TextField;
import com.sun.webui.jsf.model.SingleSelectOptionsList;
import javax.faces.FacesException;
import investigaciones_itm.RequestBean1;
import investigaciones_itm.ApplicationBean1;
import investigaciones_itm.SessionBean1;
//import itm.bo.presupuestos.rubroBO;
import itm.vo.presupuestos.presupuestosVO;
import java.sql.Date;
import javax.faces.component.UIComponent;
import javax.faces.component.UISelectItems;
import javax.faces.component.html.HtmlCommandButton;
import javax.faces.component.html.HtmlInputText;
import javax.faces.component.html.HtmlInputTextarea;
import javax.faces.component.html.HtmlMessages;
import javax.faces.component.html.HtmlOutputText;
import javax.faces.component.html.HtmlPanelGrid;
import javax.faces.context.FacesContext;

/**
 * <p>Page bean that corresponds to a similarly named JSP page.  This
 * class contains component definitions (and initialization code) for
 * all components that you have defined on this page, as well as
 * lifecycle methods and event handlers where you may add behavior
 * to respond to incoming events.</p>
 *
 * @author Administrador
 */
public class CrearSubRubro extends AbstractPageBean {
    // <editor-fold defaultstate="collapsed" desc="Managed Component Definition">

    /**
     * <p>Automatically managed component initialization.  <strong>WARNING:</strong>
     * This method is automatically generated, so any user-specified code inserted
     * here is subject to being replaced.</p>
     */
    private void _init() throws Exception {
        rubrosBDDefaultOptions.setOptions(new com.sun.webui.jsf.model.Option[]{new com.sun.webui.jsf.model.Option("item1", "Seleccione... "), new com.sun.webui.jsf.model.Option("item2", "Elemento 2"), new com.sun.webui.jsf.model.Option("item3", "Elemento 3")});
        componenteBDDefaultOptions.setOptions(new com.sun.webui.jsf.model.Option[]{new com.sun.webui.jsf.model.Option("item1", "Seleccione... "), new com.sun.webui.jsf.model.Option("item2", "Elemento 2"), new com.sun.webui.jsf.model.Option("item3", "Elemento 3")});
    }

    private Page page1 = new Page();
    
    public Page getPage1() {
        return page1;
    }
    
    public void setPage1(Page p) {
        this.page1 = p;
    }
    
    private Html html1 = new Html();
    
    public Html getHtml1() {
        return html1;
    }
    
    public void setHtml1(Html h) {
        this.html1 = h;
    }
    
    private Head head1 = new Head();
    
    public Head getHead1() {
        return head1;
    }
    
    public void setHead1(Head h) {
        this.head1 = h;
    }
    
    private Link link1 = new Link();
    
    public Link getLink1() {
        return link1;
    }
    
    public void setLink1(Link l) {
        this.link1 = l;
    }
    
    private Body body1 = new Body();
    
    public Body getBody1() {
        return body1;
    }
    
    public void setBody1(Body b) {
        this.body1 = b;
    }
    
    private Form form1 = new Form();
    
    public Form getForm1() {
        return form1;
    }
    
    public void setForm1(Form f) {
        this.form1 = f;
    }
    private HtmlPanelGrid gridPanel1 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel1() {
        return gridPanel1;
    }

    public void setGridPanel1(HtmlPanelGrid hpg) {
        this.gridPanel1 = hpg;
    }
    private TabSet tabSet1 = new TabSet();

    public TabSet getTabSet1() {
        return tabSet1;
    }

    public void setTabSet1(TabSet ts) {
        this.tabSet1 = ts;
    }
    private Tab tabIngresoSubRubro = new Tab();

    public Tab getTabIngresoSubRubro() {
        return tabIngresoSubRubro;
    }

    public void setTabIngresoSubRubro(Tab t) {
        this.tabIngresoSubRubro = t;
    }
    private PanelLayout panelCreargrupo = new PanelLayout();

    public PanelLayout getPanelCreargrupo() {
        return panelCreargrupo;
    }

    public void setPanelCreargrupo(PanelLayout pl) {
        this.panelCreargrupo = pl;
    }
    private HtmlPanelGrid panelPrincipal = new HtmlPanelGrid();

    public HtmlPanelGrid getPanelPrincipal() {
        return panelPrincipal;
    }

    public void setPanelPrincipal(HtmlPanelGrid hpg) {
        this.panelPrincipal = hpg;
    }
    private HtmlPanelGrid panelNombre = new HtmlPanelGrid();

    public HtmlPanelGrid getPanelNombre() {
        return panelNombre;
    }

    public void setPanelNombre(HtmlPanelGrid hpg) {
        this.panelNombre = hpg;
    }
    private HtmlPanelGrid p1 = new HtmlPanelGrid();

    public HtmlPanelGrid getP1() {
        return p1;
    }

    public void setP1(HtmlPanelGrid hpg) {
        this.p1 = hpg;
    }
    private HtmlOutputText labelNombre = new HtmlOutputText();

    public HtmlOutputText getLabelNombre() {
        return labelNombre;
    }

    public void setLabelNombre(HtmlOutputText hot) {
        this.labelNombre = hot;
    }
    private HtmlPanelGrid p3 = new HtmlPanelGrid();

    public HtmlPanelGrid getP3() {
        return p3;
    }

    public void setP3(HtmlPanelGrid hpg) {
        this.p3 = hpg;
    }
    private HtmlOutputText labelMision = new HtmlOutputText();

    public HtmlOutputText getLabelMision() {
        return labelMision;
    }

    public void setLabelMision(HtmlOutputText hot) {
        this.labelMision = hot;
    }
    private HtmlPanelGrid p2 = new HtmlPanelGrid();

    public HtmlPanelGrid getP2() {
        return p2;
    }

    public void setP2(HtmlPanelGrid hpg) {
        this.p2 = hpg;
    }
    private HtmlPanelGrid p4 = new HtmlPanelGrid();

    public HtmlPanelGrid getP4() {
        return p4;
    }

    public void setP4(HtmlPanelGrid hpg) {
        this.p4 = hpg;
    }
    private HtmlInputTextarea areaMision = new HtmlInputTextarea();

    public HtmlInputTextarea getAreaMision() {
        return areaMision;
    }

    public void setAreaMision(HtmlInputTextarea hit) {
        this.areaMision = hit;
    }
    private HtmlPanelGrid p5 = new HtmlPanelGrid();

    public HtmlPanelGrid getP5() {
        return p5;
    }

    public void setP5(HtmlPanelGrid hpg) {
        this.p5 = hpg;
    }
    private HtmlOutputText labelVision = new HtmlOutputText();

    public HtmlOutputText getLabelVision() {
        return labelVision;
    }

    public void setLabelVision(HtmlOutputText hot) {
        this.labelVision = hot;
    }
    private HtmlPanelGrid p6 = new HtmlPanelGrid();

    public HtmlPanelGrid getP6() {
        return p6;
    }

    public void setP6(HtmlPanelGrid hpg) {
        this.p6 = hpg;
    }
    private HtmlInputTextarea areaVision = new HtmlInputTextarea();

    public HtmlInputTextarea getAreaVision() {
        return areaVision;
    }

    public void setAreaVision(HtmlInputTextarea hit) {
        this.areaVision = hit;
    }
    private HtmlPanelGrid p7 = new HtmlPanelGrid();

    public HtmlPanelGrid getP7() {
        return p7;
    }

    public void setP7(HtmlPanelGrid hpg) {
        this.p7 = hpg;
    }
    private HtmlOutputText labelPolitica = new HtmlOutputText();

    public HtmlOutputText getLabelPolitica() {
        return labelPolitica;
    }

    public void setLabelPolitica(HtmlOutputText hot) {
        this.labelPolitica = hot;
    }
    private HtmlPanelGrid p8 = new HtmlPanelGrid();

    public HtmlPanelGrid getP8() {
        return p8;
    }

    public void setP8(HtmlPanelGrid hpg) {
        this.p8 = hpg;
    }
    private HtmlInputTextarea areaPoliticas = new HtmlInputTextarea();

    public HtmlInputTextarea getAreaPoliticas() {
        return areaPoliticas;
    }

    public void setAreaPoliticas(HtmlInputTextarea hit) {
        this.areaPoliticas = hit;
    }
    private HtmlPanelGrid p13 = new HtmlPanelGrid();

    public HtmlPanelGrid getP13() {
        return p13;
    }

    public void setP13(HtmlPanelGrid hpg) {
        this.p13 = hpg;
    }
    private HtmlOutputText labelFecha = new HtmlOutputText();

    public HtmlOutputText getLabelFecha() {
        return labelFecha;
    }

    public void setLabelFecha(HtmlOutputText hot) {
        this.labelFecha = hot;
    }
    private HtmlPanelGrid p14 = new HtmlPanelGrid();

    public HtmlPanelGrid getP14() {
        return p14;
    }

    public void setP14(HtmlPanelGrid hpg) {
        this.p14 = hpg;
    }
    private Calendar calendarioFechaRubro = new Calendar();

    public Calendar getCalendarioFechaRubro() {
        return calendarioFechaRubro;
    }

    public void setCalendarioFechaRubro(Calendar c) {
        this.calendarioFechaRubro = c;
    }
    private HtmlPanelGrid panelBoton = new HtmlPanelGrid();

    public HtmlPanelGrid getPanelBoton() {
        return panelBoton;
    }

    public void setPanelBoton(HtmlPanelGrid hpg) {
        this.panelBoton = hpg;
    }
    private HtmlPanelGrid p15 = new HtmlPanelGrid();

    public HtmlPanelGrid getP15() {
        return p15;
    }

    public void setP15(HtmlPanelGrid hpg) {
        this.p15 = hpg;
    }
    private HtmlCommandButton botonGuardar = new HtmlCommandButton();

    public HtmlCommandButton getBotonGuardar() {
        return botonGuardar;
    }

    public void setBotonGuardar(HtmlCommandButton hcb) {
        this.botonGuardar = hcb;
    }
    private HtmlPanelGrid p16 = new HtmlPanelGrid();

    public HtmlPanelGrid getP16() {
        return p16;
    }

    public void setP16(HtmlPanelGrid hpg) {
        this.p16 = hpg;
    }
    private HtmlCommandButton botonCancelar = new HtmlCommandButton();

    public HtmlCommandButton getBotonCancelar() {
        return botonCancelar;
    }

    public void setBotonCancelar(HtmlCommandButton hcb) {
        this.botonCancelar = hcb;
    }
    private HtmlPanelGrid p9 = new HtmlPanelGrid();

    public HtmlPanelGrid getP9() {
        return p9;
    }

    public void setP9(HtmlPanelGrid hpg) {
        this.p9 = hpg;
    }
    private HtmlOutputText labelMail = new HtmlOutputText();

    public HtmlOutputText getLabelMail() {
        return labelMail;
    }

    public void setLabelMail(HtmlOutputText hot) {
        this.labelMail = hot;
    }
    private HtmlPanelGrid p10 = new HtmlPanelGrid();

    public HtmlPanelGrid getP10() {
        return p10;
    }

    public void setP10(HtmlPanelGrid hpg) {
        this.p10 = hpg;
    }
    private HtmlInputText textEmail = new HtmlInputText();

    public HtmlInputText getTextEmail() {
        return textEmail;
    }

    public void setTextEmail(HtmlInputText hit) {
        this.textEmail = hit;
    }
    private HtmlPanelGrid panelMensajes = new HtmlPanelGrid();

    public HtmlPanelGrid getPanelMensajes() {
        return panelMensajes;
    }

    public void setPanelMensajes(HtmlPanelGrid hpg) {
        this.panelMensajes = hpg;
    }

    private DefaultSelectItemsArray listbox1DefaultItems = new DefaultSelectItemsArray();

    public DefaultSelectItemsArray getListbox1DefaultItems() {
        return listbox1DefaultItems;
    }

    public void setListbox1DefaultItems(DefaultSelectItemsArray dsia) {
        this.listbox1DefaultItems = dsia;
    }
    private UISelectItems listbox1SelectItems = new UISelectItems();

    public UISelectItems getListbox1SelectItems() {
        return listbox1SelectItems;
    }

    public void setListbox1SelectItems(UISelectItems uisi) {
        this.listbox1SelectItems = uisi;
    }

    private DefaultSelectItemsArray listbox2DefaultItems = new DefaultSelectItemsArray();

    public DefaultSelectItemsArray getListbox2DefaultItems() {
        return listbox2DefaultItems;
    }

    public void setListbox2DefaultItems(DefaultSelectItemsArray dsia) {
        this.listbox2DefaultItems = dsia;
    }
    private UISelectItems listbox2SelectItems = new UISelectItems();

    public UISelectItems getListbox2SelectItems() {
        return listbox2SelectItems;
    }

    public void setListbox2SelectItems(UISelectItems uisi) {
        this.listbox2SelectItems = uisi;
    }
    private HtmlPanelGrid gridPanel15 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel15() {
        return gridPanel15;
    }

    public void setGridPanel15(HtmlPanelGrid hpg) {
        this.gridPanel15 = hpg;
    }
    private HtmlCommandButton buttonSubRubro = new HtmlCommandButton();

    public HtmlCommandButton getButtonSubRubro() {
        return buttonSubRubro;
    }

    public void setButtonSubRubro(HtmlCommandButton hcb) {
        this.buttonSubRubro = hcb;
    }
    private HtmlMessages messageList1 = new HtmlMessages();

    public HtmlMessages getMessageList1() {
        return messageList1;
    }

    public void setMessageList1(HtmlMessages hm) {
        this.messageList1 = hm;
    }
    private DropDown rubrosBD = new DropDown();

    public DropDown getRubrosBD() {
        return rubrosBD;
    }

    public void setRubrosBD(DropDown dd) {
        this.rubrosBD = dd;
    }
    private SingleSelectOptionsList rubrosBDDefaultOptions = new SingleSelectOptionsList();

    public SingleSelectOptionsList getRubrosBDDefaultOptions() {
        return rubrosBDDefaultOptions;
    }

    public void setRubrosBDDefaultOptions(SingleSelectOptionsList ssol) {
        this.rubrosBDDefaultOptions = ssol;
    }
    private HtmlPanelGrid p11 = new HtmlPanelGrid();

    public HtmlPanelGrid getP11() {
        return p11;
    }

    public void setP11(HtmlPanelGrid hpg) {
        this.p11 = hpg;
    }
    private HtmlOutputText labelNombreComponente = new HtmlOutputText();

    public HtmlOutputText getLabelNombreComponente() {
        return labelNombreComponente;
    }

    public void setLabelNombreComponente(HtmlOutputText hot) {
        this.labelNombreComponente = hot;
    }
    private HtmlPanelGrid p12 = new HtmlPanelGrid();

    public HtmlPanelGrid getP12() {
        return p12;
    }

    public void setP12(HtmlPanelGrid hpg) {
        this.p12 = hpg;
    }
    private DropDown componenteBD = new DropDown();

    public DropDown getComponenteBD() {
        return componenteBD;
    }

    public void setComponenteBD(DropDown dd) {
        this.componenteBD = dd;
    }
    private SingleSelectOptionsList componenteBDDefaultOptions = new SingleSelectOptionsList();

    public SingleSelectOptionsList getComponenteBDDefaultOptions() {
        return componenteBDDefaultOptions;
    }

    public void setComponenteBDDefaultOptions(SingleSelectOptionsList ssol) {
        this.componenteBDDefaultOptions = ssol;
    }
    private HtmlPanelGrid p17 = new HtmlPanelGrid();

    public HtmlPanelGrid getP17() {
        return p17;
    }

    public void setP17(HtmlPanelGrid hpg) {
        this.p17 = hpg;
    }
    private HtmlOutputText labelNombreSubRubro = new HtmlOutputText();

    public HtmlOutputText getLabelNombreSubRubro() {
        return labelNombreSubRubro;
    }

    public void setLabelNombreSubRubro(HtmlOutputText hot) {
        this.labelNombreSubRubro = hot;
    }
    private HtmlPanelGrid p18 = new HtmlPanelGrid();

    public HtmlPanelGrid getP18() {
        return p18;
    }

    public void setP18(HtmlPanelGrid hpg) {
        this.p18 = hpg;
    }
    private TextField textFieldSubRubro = new TextField();

    public TextField getTextFieldSubRubro() {
        return textFieldSubRubro;
    }

    public void setTextFieldSubRubro(TextField tf) {
        this.textFieldSubRubro = tf;
    }

    // </editor-fold>

    /**
     * <p>Construct a new Page bean instance.</p>
     */
    public CrearSubRubro() {
    }

    /**
     * <p>Callback method that is called whenever a page is navigated to,
     * either directly via a URL, or indirectly via page navigation.
     * Customize this method to acquire resources that will be needed
     * for event handlers and lifecycle methods, whether or not this
     * page is performing post back processing.</p>
     * 
     * <p>Note that, if the current request is a postback, the property
     * values of the components do <strong>not</strong> represent any
     * values submitted with this request.  Instead, they represent the
     * property values that were saved for this view when it was rendered.</p>
     */
    @Override
    public void init() {
        // Perform initializations inherited from our superclass
        super.init();
        // Perform application initialization that must complete
        // *before* managed components are initialized
        // TODO - add your own initialiation code here
        
        // <editor-fold defaultstate="collapsed" desc="Managed Component Initialization">
        // Initialize automatically managed components
        // *Note* - this logic should NOT be modified
        try {
            _init();
        } catch (Exception e) {
            log("CrearGrupos Initialization Failure", e);
            throw e instanceof FacesException ? (FacesException) e: new FacesException(e);
        }
        
        // </editor-fold>
        // Perform application initialization that must complete
        // *after* managed components are initialized
        // TODO - add your own initialization code here
    }

    /**
     * <p>Callback method that is called after the component tree has been
     * restored, but before any event processing takes place.  This method
     * will <strong>only</strong> be called on a postback request that
     * is processing a form submit.  Customize this method to allocate
     * resources that will be required in your event handlers.</p>
     */
    @Override
    public void preprocess() {
    }

    /**
     * <p>Callback method that is called just before rendering takes place.
     * This method will <strong>only</strong> be called for the page that
     * will actually be rendered (and not, for example, on a page that
     * handled a postback and then navigated to a different page).  Customize
     * this method to allocate resources that will be required for rendering
     * this page.</p>
     */
    @Override
    public void prerender() {
    }

    /**
     * <p>Callback method that is called after rendering is completed for
     * this request, if <code>init()</code> was called (regardless of whether
     * or not this was the page that was actually rendered).  Customize this
     * method to release resources acquired in the <code>init()</code>,
     * <code>preprocess()</code>, or <code>prerender()</code> methods (or
     * acquired during execution of an event handler).</p>
     */
    @Override
    public void destroy() {
    }

    /**
     * <p>Return a reference to the scoped data bean.</p>
     *
     * @return reference to the scoped data bean
     */
    protected RequestBean1 getRequestBean1() {
        return (RequestBean1) getBean("RequestBean1");
    }

    /**
     * <p>Return a reference to the scoped data bean.</p>
     *
     * @return reference to the scoped data bean
     */
    protected ApplicationBean1 getApplicationBean1() {
        return (ApplicationBean1) getBean("ApplicationBean1");
    }

    /**
     * <p>Return a reference to the scoped data bean.</p>
     *
     * @return reference to the scoped data bean
     */
    protected SessionBean1 getSessionBean1() {
        return (SessionBean1) getBean("SessionBean1");
    }
    
    private presupuestosVO rubroVO;
 //   private presupuestosBO rubroBO;

    
    private String nRubro="";
    private int idRubro=0;
    private Date fechaRegistro=null;
        
    public String botonGuardar_action() throws Exception{
        // TODO: Process the button click action. Return value is a navigation
        // case name where null will return to the same page.
     /*   try{
            rubroVO= new rubroVO();
            rubroBO= new rubroBO();
            nombreRubro=(String) areaNombreRubro.getValue();
            
            java.util.Date fechaCalendario = (java.util.Date) calendarioFechaRubro.getValue();
            if(nombreRubro==null || nombreRubro.equals("")){
                error("Por favor digite el nombre del grupo de investigación.");
                return null;
            }else if(fechaCalendario==null){
                error("Por favor digite la fecha de registro del grupo de investigación.");
                return null;
            }//else if(!getEmail().contains("@")){
              //  error("Por favor digite el E-mail correcto.");
              // return null;
            //}            
            fechaRegistro = new Date(fechaCalendario.getTime());
            rubroVO.setNombreGrupo(nombreGrupo);
            rubroVO.setFechaRegistro(fechaRegistro);
            idRubro=rubroBO.crearRubro(rubroVO);
            if(idRubro==0){
                error("Error al insertar el grupo de investigación.");
            }else{
                textFieldIdRubro.setValue(idRubro);
                info("El Grupo se ha creado correctamente.");
                buttonComponentes.setDisabled(false);
            }
            
        }catch(ControlException ce){
            error("Error al crear el grupo de investigación.");
            ce.getStackTrace();
        }*/
        return "OK";
    }
    
    public String button2_action() {
        // TODO: Process the button click action. Return value is a navigation
        // case name where null will return to the same page.
        
        return null;
    }

    public String tabIngresoSubRubro_action() {
        // TODO: Replace with your code
        return null;
    }

    public String button3_action() {
        // TODO: Process the button click action. Return value is a navigation
        // case name where null will return to the same page.
        tabSet1.setSelected(tabIngresoSubRubro.getId().toString());
        return null;
    }

    public String buttonSubRubro_action() {
        // TODO: Process the button click action. Return value is a navigation
        // case name where null will return to the same page.
        return null;
    }

    public void rubrosBD_validate(FacesContext context, UIComponent component, Object value) {
    }
}

